package com.sxy.anli.service;

import com.sxy.anli.mapper.UserMapper;
import com.sxy.anli.pojo.User;
import com.sxy.anli.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
public class UserService {
    //创建SqlSessionFactory对象
    private SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();

    public void select(String username, String password) {
        //创建sqlSession对象
        SqlSession sqlSession = sqlSessionFactory.openSession();
        //创建mapper对象
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);
        //执行sql,返回user对象
        User user = mapper.select(username, password);
        //判断数据库中是否有user对象
        if (user == null) {
            sqlSession.close();
            return;
        }


    }
}
